<?php

	require_once APPPATH . 'controllers/base_controllers/base_controller.php';
	
	class member extends Base_controller
	{
		public static $REGISTRATION_TEMPLATE = 'templates/registration/registration_template';		

		public function __construct()
		{
			parent::__construct();

			$this->load->model('values/cwr_registrant_member_homepage_value');
			
			$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
        	$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
       		$this->output->set_header('Pragma: no-cache');
        	$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");		
		}		

		public function login_register( $loginFailed = false )
		{
			$this->load->model('proxies/Walk_proxy');

			$data['title'] = 'CMB Member Login for Existing Member Registration';
            $data['curyear'] = $this->Walk_proxy->getCurrentYear();
			$data['loginFailed'] = $loginFailed;

            if ($this->Walk_proxy->isRegistrationOpen())
            {
                $data['view'] = 'cmb/register/login_register_view';
            }
            else
            {
                $datesBV = $this->Walk_proxy->getCurrentBVEventDates($this->Walk_proxy->getCurrentYear());
                $data['open_date'] = $datesBV[2];               
                $data['view'] = 'cmb/register/registration_closed_view';
            }

            $this->load->view( 'templates/registration/registration_template', $data );
		}

        public function login_teacher_register( $loginFailed = false )
        {
            $this->load->model('proxies/Walk_proxy');

            $data['title'] = 'CMB Teacher Login for Existing Member Registration';
            $data['curyear'] = $this->Walk_proxy->getCurrentYear();
            $data['loginFailed'] = $loginFailed;

            if ($this->Walk_proxy->isTeacherRegistrationOpen())
            {
                $data['view'] = 'cmb/register/login_teacher_register_view';
            }
            else
            {
                $datesBV = $this->Walk_proxy->getCurrentBVEventDates($this->Walk_proxy->getCurrentYear());
                $data['open_date'] = $datesBV[4];               
                $data['view'] = 'cmb/register/registration_teacher_closed_view';
            }

            $this->load->view( 'templates/registration/registration_template', $data );
        }

		public function login_pay_registration( $loginFailed = false )
		{
			$this->load->model('proxies/Walk_proxy');

			$data['title'] = 'Login for CMB Member Registration Payment';
			$data['view'] = 'cmb/register/login_pay_registration_view';
			$data['loginFailed'] = $loginFailed;

			$this->load->view( 'templates/registration/registration_template', $data );
		}

		public function login_superadmin( $loginFailed = false )
		{
			$this->load->model('proxies/Admin_proxy');

			$data['title'] = ' Super Admin Login ';
			$data['view'] = 'cmb/register/login_superadmin_view';
			$data['loginFailed'] = $loginFailed;

			$this->load->view( 'templates/registration/registration_template', $data );
		}

		public function login_home_metrowest( $loginFailed = false )
		{
			$this->load->model('proxies/Walk_proxy');

			$data['title'] = 'MetroWest Existing Member Login';
			$data['view'] = 'cmb/register/login_home_mw_view';
			$data['loginFailed'] = $loginFailed;
			
			$this->load->view( 'templates/registration/registration_template', $data );
		}

        public function login_home( $loginFailed = false )
        {
            $this->load->model('proxies/Walk_proxy');

            $data['title'] = 'Existing Member Login';
            $data['view'] = 'cmb/register/login_home_view';
            $data['loginFailed'] = $loginFailed;
            
            $this->load->view( 'templates/registration/registration_template', $data );
        }

		public function login_superadmin_process()
		{
			$this->load->model('proxies/Security_proxy');
			$this->load->model('proxies/Admin_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');

			$personId = $this->Security_proxy->authenticate( $this->input->post('userName'), $this->input->post('password') );			
			$this->session->set_userdata( 'person_id', $personId );
			if( $personId > 0 )
			{					
				if ($this->Person_proxy->isPersonRole( $personId, "superadmin" ))
				{
					$this->session->set_userdata( 'superadmin_is_logged_in', true );
					//$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getHouseholdPrimaryPersonSecurityKey( $personId ) );
					$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getPersonSecurityKey( $personId ) );
			
					$this->load->model('values/cwr_registrant_member_homepage_value');
					$this->load->model('proxies/Cwr_registrant_member_proxy');
			
					//Make sure person has registered with cmb
					$cmbRegHistoryId = $this->Walk_proxy->getCMBRegHistoryIdfromPerson( $personId );
					if ($cmbRegHistoryId == 0)
					{
						redirect( base_url() . 'cmb/member/homepage_error/');
					}
				
					//Check if registration contains a 'urlKey'
					$memURLKey = $this->Walk_proxy->getMemberURLKey( $cmbRegHistoryId );

					if ($memURLKey != "")
					{
						redirect( base_url() . 'cmb/member/superadmin_home/' . $memURLKey . '/' );
					}
					else
						redirect( base_url() . 'cmb/member/homepage_error/');
				}
				else
				{
					$this->session->set_userdata( 'superadmin_is_logged_in', false );
					$this->session->set_userdata( 'logged_in_key', '' );
					redirect( base_url() . 'cmb/member/login_superadmin/true/' );					
				}
			}
			else
			{
				$this->session->set_userdata( 'superadmin_is_logged_in', false );
				$this->session->set_userdata( 'logged_in_key', '' );
				redirect( base_url() . 'cmb/member/login_superadmin/true/' );
			}

			die;
		}

		//Register existing member directly upon login
		public function login_register_process()
		{
			$this->load->model('proxies/Security_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			
				$personId = $this->Security_proxy->authenticate( $this->input->post('userName'), $this->input->post('password') );
				$this->session->set_userdata( 'person_id', $personId );
				if( $personId > 0 )
				{
					//Check that nonmember does not login and register
					if (!$this->Person_proxy->isPersonGroup( $personId, "nonmember" ))
					{
						$curyear = $this->Walk_proxy->getCurrentYear();
				
						//Make sure person has registered with cmb
						$cmbRegHistoryId = $this->Walk_proxy->getCMBRegHistoryIdfromPerson( $personId );
						if ($cmbRegHistoryId == 0)
						{
							redirect( base_url() . 'cmb/member/homepage_error/');
						}
				
						//Check if registration contains a 'urlKey'
						$memURLKey = $this->Walk_proxy->getMemberURLKey( $cmbRegHistoryId );
						if ($memURLKey == "")
						{
							//Create a new 'urlKey' and update
							$memURLKey = $this->Walk_proxy->createRegistrationURLKey( $cmbRegHistoryId );
							if ($memURLKey == "")
							{
								redirect( base_url() . 'cmb/member/homepage_error/');
							}		
						}
							
						$this->session->set_userdata( 'is_logged_in', true );
						//$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getHouseholdPrimaryPersonSecurityKey( $personId ) );
						$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getPersonSecurityKey( $personId ) );
			
						redirect( base_url() . 'cmb/member_registration/register_existing_member/'.$memURLKey.'/' );
					}
					else
					{
						$this->session->set_userdata( 'is_logged_in', false );
						$this->session->set_userdata( 'logged_in_key', '' );
						redirect( base_url() . 'cmb/member/login_register/true/' );						
					}
				}
				else
				{
					$this->session->set_userdata( 'is_logged_in', false );
					$this->session->set_userdata( 'logged_in_key', '' );
					redirect( base_url() . 'cmb/member/login_register/true/' );
				}
			
			die;
		}

        //Register existing teacher member directly upon login
        public function login_register_teacher_process()
        {
            $this->load->model('proxies/Security_proxy');
            $this->load->model('proxies/Walk_proxy');
            $this->load->model('proxies/Person_proxy');
            
                $personId = $this->Security_proxy->authenticate( $this->input->post('userName'), $this->input->post('password') );
                $this->session->set_userdata( 'person_id', $personId );
                if( $personId > 0 )
                {
                    //Check that nonmember does not login and register
                    if (!$this->Person_proxy->isPersonGroup( $personId, "nonmember" ))
                    {
                        $curyear = $this->Walk_proxy->getCurrentYear();
                
                        //Make sure person has registered with cmb
                        $cmbRegHistoryId = $this->Walk_proxy->getCMBRegHistoryIdfromPerson( $personId );
                        if ($cmbRegHistoryId == 0)
                        {
                            redirect( base_url() . 'cmb/member/homepage_error/');
                        }
                
                        //Check if registration contains a 'urlKey'
                        $memURLKey = $this->Walk_proxy->getMemberURLKey( $cmbRegHistoryId );
                        if ($memURLKey == "")
                        {
                            //Create a new 'urlKey' and update
                            $memURLKey = $this->Walk_proxy->createRegistrationURLKey( $cmbRegHistoryId );
                            if ($memURLKey == "")
                            {
                                redirect( base_url() . 'cmb/member/homepage_error/');
                            }       
                        }
                            
                        $this->session->set_userdata( 'is_logged_in', true );
                        //$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getHouseholdPrimaryPersonSecurityKey( $personId ) );
                        $this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getPersonSecurityKey( $personId ) );
            
                        redirect( base_url() . 'cmb/member_registration/register_existing_teacher_member/'.$memURLKey.'/' );
                    }
                    else
                    {
                        $this->session->set_userdata( 'is_logged_in', false );
                        $this->session->set_userdata( 'logged_in_key', '' );
                        redirect( base_url() . 'cmb/member/login_teacher_register/true/' );                     
                    }
                }
                else
                {
                    $this->session->set_userdata( 'is_logged_in', false );
                    $this->session->set_userdata( 'logged_in_key', '' );
                    redirect( base_url() . 'cmb/member/login_teacher_register/true/' );
                }
            
            die;
        }

		//Member login to pay for existing registration
		public function login_pay_registration_process()
		{
			$this->load->model('proxies/Security_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			
				$personId = $this->Security_proxy->authenticate( $this->input->post('userName'), $this->input->post('password') );
				$this->session->set_userdata( 'person_id', $personId );			
				if( $personId > 0 )
				{
					//Check that nonmember does not login and register
					if (!$this->Person_proxy->isPersonGroup( $personId, "nonmember" ))
					{
						$curyear = $this->Walk_proxy->getCurrentYear();
				
						//Make sure person has registered with cmb for current year
						$cmbRegHistoryId = $this->Walk_proxy->getCMBRegHistoryIdfromPersonYear( $personId, $curyear );
						if ($cmbRegHistoryId == 0)
						{
							redirect( base_url() . 'cmb/member/homepage_error/');
						}
				
						//Check if registration contains a 'urlKey'
						$memURLKey = $this->Walk_proxy->getMemberURLKey( $cmbRegHistoryId );
						if ($memURLKey == "")
						{
							redirect( base_url() . 'cmb/member/homepage_error/');		
						}
							
						$this->session->set_userdata( 'is_logged_in', true );
						//$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getHouseholdPrimaryPersonSecurityKey( $personId ) );
						$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getPersonSecurityKey( $personId ) );
			
						redirect( base_url() . 'cmb/member_registration/member_registration_payment/'.$memURLKey.'/' );
					}
					else
					{
						$this->session->set_userdata( 'is_logged_in', false );
						$this->session->set_userdata( 'logged_in_key', '' );
						redirect( base_url() . 'cmb/member/login_pay_registration/true/' );						
					}
				}
				else
				{
					$this->session->set_userdata( 'is_logged_in', false );
					$this->session->set_userdata( 'logged_in_key', '' );
					redirect( base_url() . 'cmb/member/login_pay_registration/true/' );
				}
			
			die;
		}

		public function login_home_process()
		{
			$this->load->model('proxies/Security_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			
			$personId = $this->Security_proxy->authenticate( $this->input->post('userName'), $this->input->post('password') );
			$this->session->set_userdata( 'person_id', $personId );			
			if( $personId > 0 )
			{
				//Check that nonmember does not login
				if (!$this->Person_proxy->isPersonGroup( $personId, "nonmember" ))
				{
					$curyear = $this->Walk_proxy->getCurrentYear();
				
					//Make sure person has registered with cmb
					$cmbRegHistoryId = $this->Walk_proxy->getCMBRegHistoryIdfromPerson( $personId );
					if ($cmbRegHistoryId == 0)
					{
						redirect( base_url() . 'cmb/member/homepage_error/');
					}
				
					//Check if registration contains a 'urlKey'
					$memURLKey = $this->Walk_proxy->getMemberURLKey( $cmbRegHistoryId );
					if ($memURLKey == "")
					{
						//Create a new 'urlKey' and update
						$memURLKey = $this->Walk_proxy->createRegistrationURLKey( $cmbRegHistoryId );
						if ($memURLKey == "")
						{
							redirect( base_url() . 'cmb/member/homepage_error/');
						}
					}
							
					if (($this->Person_proxy->isPersonGroupRole( $personId, "member", "admin" )) or ($this->Person_proxy->isPersonGroupRole( $personId, "member", "superadmin" )))
					{
						$this->session->set_userdata( 'admin_is_logged_in', true );	
						$this->session->set_userdata( 'is_logged_in', true );											
					}
					else
					{
						if (($this->Person_proxy->isPersonGroupRole( $personId, "member", "user" )) or ($this->Person_proxy->isPersonGroupRole( $personId, "member", "reportsuser" )))
						{
							$this->session->set_userdata( 'admin_is_logged_in', false );	
							$this->session->set_userdata( 'is_logged_in', true );
						}
						else
						{
							$this->session->set_userdata( 'is_logged_in', false );
							$this->session->set_userdata( 'admin_is_logged_in', false );
							$this->session->set_userdata( 'logged_in_key', '' );
							redirect( base_url() . 'cmb/member/login_home/true/' );							
						}
					}
					
					//$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getHouseholdPrimaryPersonSecurityKey( $personId ) );
					$this->session->set_userdata( 'logged_in_key', $this->Person_proxy->getPersonSecurityKey( $personId ) );
			
					redirect( base_url() . 'cmb/member/home/' . $memURLKey . '/' );
				}
				else
				{
					$this->session->set_userdata( 'is_logged_in', false );
					$this->session->set_userdata( 'admin_is_logged_in', false );
					$this->session->set_userdata( 'logged_in_key', '' );
					redirect( base_url() . 'cmb/member/login_home/true/' );					
				}
			}
			else
			{
				$this->session->set_userdata( 'is_logged_in', false );
				$this->session->set_userdata( 'admin_is_logged_in', false );
				$this->session->set_userdata( 'logged_in_key', '' );
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			die;
		}

		public function home( $urlKey )
		{
			$this->load->library('encrypt');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');

			$is_logged_in = ($this->session->userdata( 'is_logged_in' ) or $this->session->userdata( 'admin_is_logged_in' ));
			
			if ($is_logged_in)
			{
				$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
				//$seckey = $this->Person_proxy->getPrimaryPersonSecurityKey( $urlKey );			
				if ($seckey != $this->session->userdata( 'logged_in_key' ))
				{
					$this->session->set_userdata( 'is_logged_in', false );
					$this->session->set_userdata( 'admin_is_logged_in', false );
					redirect( base_url() . 'cmb/member/login_home/true/' );
				}

				//Get id for person who logged in
				$loginPersonId = $this->session->userdata( 'person_id' );
				if ( $loginPersonId < 1 )
				{
					redirect( base_url() . 'cmb/member/login_home/true/' );
				}

				$curyear = $this->Walk_proxy->getCurrentYear();
				$this->load->model('values/cwr_registrant_member_homepage_value');
				$this->load->model('proxies/Cwr_registrant_member_proxy');
				
				$cwr_registrant_home_value = Cwr_registrant_member_homepage_value::cast($this->Cwr_registrant_member_proxy->getRegistrantMemberHomepageFromUrl_noyr( $urlKey ));
				if (!$cwr_registrant_home_value->getIsRegistered())
				{
					$this->session->set_userdata( 'is_logged_in', false );
					$this->session->set_userdata( 'admin_is_logged_in', false );
					redirect( base_url() . 'cmb/member/homepage_error/');
				}
				
				$data['curyear'] = $curyear;
				$data['personrole'] = $this->Person_proxy->getPersonRole( $this->session->userdata( 'person_id' ) );
				$data['persongroup'] = $this->Person_proxy->getPersonGroup( $this->session->userdata( 'person_id' ) );
				$data['loggedinname'] = $this->Person_proxy->getPersonName( $loginPersonId );

				//if (($this->Person_proxy->isPersonGroupRole( $this->session->userdata( 'person_id' ), "member", "admin" )) or ($this->Person_proxy->isPersonGroupRole( $cwr_registrant_home_value->getPersonId(), "member", "superadmin" )))
				if (($this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "admin" )) or ($this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "superadmin" )))
				{
					//Users with admin role
					$data['title'] = 'Chinmaya Mission Boston Admin Member Home';
					$data['view'] = 'cmb/member/admin_home_view';
					$data['cwr_registrant_home_value'] = $cwr_registrant_home_value;
					$data['urlKey'] = $urlKey;
			
					$this->load->view( 'templates/registration/registration_template', $data );
				}
				else
				{
                    if (($this->Person_proxy->isPersonGroupRole( $loginPersonId, "balavihar", "user" )))
                    {
                        //Balavihar users
                        $data['title'] = 'Chinmaya Mission Boston Balavihar Teacher Home';
                        $data['view'] = 'cmb/member/balavihar_home_view';
                        $data['cwr_registrant_home_value'] = $cwr_registrant_home_value;
                        $data['urlKey'] = $urlKey;
                
                        $this->load->view( 'templates/registration/registration_template', $data );
                    }
                    else
                    {
                        if (($this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "user" )) or ($this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "reportsuser" )))
                        {                   
                            $data['title'] = 'Chinmaya Mission Boston Member Home';
                            $data['view'] = 'cmb/member/member_home_view';
                            $data['cwr_registrant_home_value'] = $cwr_registrant_home_value;
                            $data['urlKey'] = $urlKey;
                
                            $this->load->view( 'templates/registration/registration_template', $data );
                        }                   
                        else
                        {
                            $this->session->set_userdata( 'is_logged_in', false );
                            $this->session->set_userdata( 'admin_is_logged_in', false );
                            redirect( base_url() . 'cmb/member/login_home/true/' );
                        }                    
                    }
				}				
			}
			else
			{
				$this->session->set_userdata( 'is_logged_in', false );
				$this->session->set_userdata( 'admin_is_logged_in', false );
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
		}
		
		public function superadmin_home( $urlKey )
		{
			$this->load->library('encrypt');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');

			$is_logged_in = $this->session->userdata( 'superadmin_is_logged_in' );
			
			if ($is_logged_in)
			{
				//$seckey = $this->Person_proxy->getPrimaryPersonSecurityKey( $urlKey );			
				$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
				if ($seckey != $this->session->userdata( 'logged_in_key' ))
				{
					redirect( base_url() . 'cmb/member/login_superadmin/true/' );
				}

				$curyear = $this->Walk_proxy->getCurrentYear();
				$this->load->model('values/cwr_registrant_member_homepage_value');
				$this->load->model('proxies/Cwr_registrant_member_proxy');
			
				$cwr_registrant_home_value = Cwr_registrant_member_homepage_value::cast($this->Cwr_registrant_member_proxy->getRegistrantMemberHomepageFromUrl_noyr( $urlKey ));
				if (!$cwr_registrant_home_value->getIsRegistered())
				{
					redirect( base_url() . 'cmb/member/homepage_error/');
				}
				
				$data['title'] = 'Super Admin Home ';
				$data['view'] = 'cmb/member/superadmin_home_view';
				$data['urlKey'] = $urlKey;
				$data['cwr_registrant_home_value'] = $cwr_registrant_home_value;
			
				$this->load->view( 'templates/registration/registration_template', $data );
			}
			else
			{
				redirect( base_url() . 'cmb/member/login_superadmin/true/' );
			}
		}

        public function forgot_password()
        {       
            $data['use_title'] = TRUE;
            $data['title'] = 'Forgot Password';
            $data['view'] = 'cmb/member/forgot_password_view';
            
            $this->load->view( 'templates/registration/registration_template', $data );
        }
   
        public function forgot_password_process()
        {
                
            $this->load->model('proxies/Person_proxy');
               
            $personLN = $this->input->post('personLN');
            $personEmail = $this->input->post('personEmail');
            
            $personID = $this->Person_proxy->findPerson( $personLN, $personEmail );
            
            if ($personID > 0)
            {
                //Create forgot_password_table entry
                $urlKey = $this->Person_proxy->createForgotPasswordEntry( $personID );
                if ($urlKey == "")
                {
                    //Handle case where there is already an active reset password entry for specified person
                   $data['title'] = 'A Reset Password Link was Already Sent';
                   $data['view'] = 'cmb/member/reset_link_already_sent_view';
                }
                else
                {
                    //Email link to reset password
                    $person_email = $this->Person_proxy->getPersonEmail( $personID );
                    
                    //User name to reset password
                    $person_username = $this->Person_proxy->getPersonUserName( $personID );

                    if ($person_email != "")
                    {
                        $this->Person_proxy->sendPersonResetPasswordEmail( $person_email, $person_username, $urlKey );
            
                        $data['title'] = 'Reset Password Link Has Been Sent';
                        $data['view'] = 'cmb/member/reset_link_sent_view';
                    }
                    else
                    {                
                        $data['title'] = 'Could not not locate person';
                        $data['view'] = 'cmb/member/person_not_found_view';
                    }
                }                
            }
            else
            {               
                $data['title'] = 'Could not not locate person';
                $data['view'] = 'cmb/member/person_not_found_view';
            }
            
            $this->load->view( 'templates/registration/registration_template', $data );
        }       

        //Reset password based on email link sent
        public function reset_password_from_email( $urlKey )
        {
             $this->load->model('proxies/Person_proxy');
                
            //Find person based on password key
            $personID = $this->Person_proxy->getPersonIDFromForgotPasswordKey( $urlKey );
            
            if ($personID < 1)
            {
                $data['title'] = 'Password Key has Expired';
                $data['view'] = 'cmb/member/password_key_expired_view';             
                //$data['title'] = 'Incorrect Reset Password Key';
                //$data['view'] = 'cmb/member/incorrect_reset_key_view';              
            }
            else
            {
                //Check if password key has expired
                if (!$this->Person_proxy->isPasswordKeyExpired( $urlKey ))
                {
                    $data['title'] = 'Reset Password';
                    $data['view'] = 'cmb/member/reset_password_email_view';
                    $data['urlKey'] = $urlKey;
                }
                else
                {
                    $data['title'] = 'Password Key has Expired';
                    $data['view'] = 'cmb/member/password_key_expired_view';             
                }           
            }
                        
            $this->load->view( 'templates/registration/registration_template', $data );
        }       

        public function reset_password_email_process( $urlKey )
        {
             $this->load->model('proxies/Person_proxy');
                
            //Find person based on password key
            $personID = $this->Person_proxy->getPersonIDFromForgotPasswordKey( $urlKey );
            
            $newPassword = $this->input->post('newpassword');
                        
            $this->Person_proxy->resetPersonPassword( $personID, $urlKey, $newPassword );

            $data['title'] = 'Password Updated';
            $data['view'] = 'cmb/member/password_updated_view';             
            
            $this->load->view( 'templates/registration/registration_template', $data );
        }       
        
		public function homepage_logout(  )
		{
			$this->session->unset_userdata( 'is_logged_in' );
			$this->session->unset_userdata( 'admin_is_logged_in' );
			$this->session->unset_userdata( 'logged_in_key');
			$this->session->sess_destroy();
			redirect( base_url() . 'cmb/member/login_home/' );
		}		

		public function homepage_superadmin_logout(  )
		{
			$this->session->unset_userdata( 'superadmin_is_logged_in' );
			$this->session->unset_userdata( 'logged_in_key');
			$this->session->unset_userdata( 'person_id' );
			$this->session->sess_destroy();
			redirect( base_url() . 'cmb/member/login_superadmin/' );
		}		

		public function homepage_error()
		{
			$this->load->model('proxies/Walk_proxy');

			$data['title'] = 'Home Page Error';
			$data['view'] = 'cmb/member/homepage_error_view';
			$data['curyear'] = $this->Walk_proxy->getCurrentYear();
			
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}		
		
		public function admin_register_error()
		{
			$this->load->model('proxies/Walk_proxy');

			$data['title'] = 'Cannot Register Admin User';
			$data['view'] = 'cmb/member/admin_register_error_view';
			
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}		
	}

?>